class Solution {
public:
    string convert(string s, int nRows) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        vector<string> strs(nRows);
        int n = s.length();
        int cur = 0;

        while (true) {
          for (int i = 0; i < nRNows && i + cur < n; ++i) {
            strs[i] += s[i + cur];
          }
          cur += nRows;
          if (nRows - 2 > 0) {
            for (int i = 0; i < nRows - 2 && i + cur < n; ++i) {
              strs[nRows - i - 2] += s[i + cur];
            }
            cur += nRows - 2;
          }
          if (cur >= n) {
            break;
          }
        }

        string result;
        for (int i = 0; i < nRows; ++i) {
          result += strs[i];
        }
        return result;
    }
};
